/** UNI 提示 */
export function useTips() {
  /**
   * 展示loading弹窗，默认不允许穿透
   * @param params 参考uni的传参
   * @returns promise
   */
  const showLoading = (params?: UniApp.ShowLoadingOptions) => {
    return new Promise((resolve, reject) => {
      uni.showLoading({
        title: '加载中...',
        mask: true,
        success() {
          resolve(null)
        },
        fail(e) {
          reject(e)
        },
        ...params,
      })
    })
  }

  /**
   * 隐藏loading
   */
  const hideLoading = () => {
    uni.hideLoading()
  }

  const tips = (title: string) => {
    uni.showToast({
      icon: 'none',
      title,
    })
  }
  return { showLoading, hideLoading, tips }
}
